<template name="train">
	<view class="">
		<cu-custom bgColor="bg-blue">
			<block slot="content">培训学院</block>
			<!-- <block slot="right">
				<button class="cu-btn shadow line-white" style="margin-right: 12rpx;" @click="goAdd()">添加</button>
			</block> -->
		</cu-custom>
		<view class="no-data">
			正在开发中
		</view>
	<!-- 	<view class="collegeList" v-if="isHave">
			<view class="list" @click="goDetail(item)" v-for="(item,index) in listPages" :key="item.id">
				<view class="imgs" v-if="item.fileType==0">
					<image :src="item.file" mode="aspectFill"></image>
				</view>
				<view class="imgs" v-if="item.fileType==1">
					<image :src="item.thumbnail" mode="aspectFill"></image>
				</view>
				<view class="info">
					<view class="name">{{item.title}}</view>
					<view class="tips">{{item.browseNum}}次浏览</view>
					<view class="name">{{item.briefDescription}}</view>
				</view>
			</view>
		</view>
		<view class="no-data" v-if="!isHave">暂无数据</view>
		<view v-if="isHave&&showMore" class="no-data">
			暂无更多
		</view> -->
	</view>
</template>
<script>
	export default {
		name: "train",
		data() {
			return {
				listPages: [],//学院课程
				page: 1,//当前页
				total: '',//总条数
				showMore: '',//暂无更多
				isHave: true //是否为空
			};
		},
		onTabItemTap(){
			// if(this.$store.state.state&&this.$store.state.isphone){
			// 	getApp().globalData.TTSSpeaker.stop();
			// 	getApp().globalData.TTSSpeaker.speak(`学院正在开发中`,1);
			// }
		},
		onShow() {
			uni.showToast({
			    title: '正在开发中',
				icon:'none'
			})
			if(this.$store.state.state&&this.$store.state.isphone){
				getApp().globalData.TTSSpeaker.stop();
				getApp().globalData.TTSSpeaker.speak(`学院正在开发中`,1);
			}
			// const that = this;
			// uni.$on("NFC_READ", function(msg) {
			// 	that.readCard(msg.rfid);
			// });
			// this.page = 1;
			// this.listPages = []
			// this.listPage()
		},
		onLoad() {
			// item.hasOldMan&&!item.outFlag"
		},
		onHide() {
			// 移除监听事件
			uni.$off("NFC_READ");
		},
		onUnload() {
			
		},
		onReachBottom() {
			if (this.page < this.total) {
				this.page++;
				this.listPage();
			} else {
				this.showMore = '暂无更多数据'
			}
		},
		methods: {
			readCard(id) {
				console.log(9999)
				this.$http('/implement-service/implement/getByRfidCardIdForService', 'get', {
					rfidCardId: id
				}).then(res => {
					console.log(res, 9999)
					if (res.data.code == 200) {
						const data = res.data.data;
						console.log(data)
						if (data.serviceTarget == 0) {
							let param = {
								id: data.serviceObject.id
							}
							this.$http('/care-service/oldBaseDetail/getOldBaseInfo', 'get', param).then(res => {
								if (res.data.data.outStatus) {
									if (this.$store.state.state && this.$store.state.isphone) {
										getApp().globalData.TTSSpeaker.stop();
										getApp().globalData.TTSSpeaker.speak('长者已经外出', 1);
									}
									uni.showToast({
										title:'长者已经外出',
										icon:'none'
									})
								} else {
									if (this.$store.state.state && this.$store.state.isphone) {
										getApp().globalData.TTSSpeaker.stop();
										getApp().globalData.TTSSpeaker.speak('进入芯片对应长者详情页面', 1);
									}
									uni.navigateTo({
										url: '/pages/basics/services/service-details?oldBaseId=' + res.data.data.oldBaseId
									})
								}
							});
						}
						if (data.serviceTarget == 1) {
							uni.navigateTo({
								url: '/pages/basics/daily/registration?roomName=' + data.serviceObject.name + '&roomId=' + data.serviceObject
									.id
							})
						}
						if (data.serviceTarget == 2) {
							uni.navigateTo({
								url: '/pages/basics/regional/area-details?id=' + data.serviceObject.id
							})
						}
					} else if (res.data.code == 2000) {
						if (this.$store.state.state && this.$store.state.isphone) {
							getApp().globalData.TTSSpeaker.stop();
							getApp().globalData.TTSSpeaker.speak(res.data.message, 1);
						}
					}
				})
			},
			// GET /collegeData/listPage 学院list分页
			listPage() {
				this.showMore = ''
				let param = {
					size: 7,
					page: this.page,
					status:2
				}
					uni.showLoading({
						title: '加载中'
					});
				this.$http('/college-service/collegeData/listPage', 'get', param).then(res => {
					if (res.data.code == 200) {
						
						this.listPages = this.listPages.concat(res.data.data.records)
						this.total = res.data.data.pages
						this.isHave = true
						if (this.listPages.length == 0) {
							this.isHave = false
						} else {
							this.isHave = true
						}
					}
						uni.hideLoading();
				});
			},
			goDetail(item) {
				if (this.$store.state.state && this.$store.state.isphone) {
					getApp().globalData.TTSSpeaker.stop();
					getApp().globalData.TTSSpeaker.speak(`点击可进入详情页面进行学习。`, 1);
						uni.navigateTo({
							url: '/pages/train/train-detail/train-detail?id=' + item.id
						})
				} else {
					uni.navigateTo({
						url: '/pages/train/train-detail/train-detail?id=' + item.id
					})
				}
			},
			goAdd() {
				if (this.$store.state.state && this.$store.state.isphone) {
					getApp().globalData.TTSSpeaker.stop();
					getApp().globalData.TTSSpeaker.speak(`添加`, 1);
				}
				uni.navigateTo({
					url: '/pages/train/add-video/add-video'
				})
			}
		}
	}
</script>

<style lang="scss">
	.page {
		height: 100vh;
	}

	.add {
		float: right;
	}

	.collegeList {
		width: 100%;
		height: auto;
		box-sizing: border-box;
		padding: 0 32rpx;

		.list {
			width: 100%;
			height: auto;
			display: flex;
			border-bottom: 1px solid #eee;
			padding: 32rpx 0;

			.imgs {
				width: 200rpx;
				height: 150rpx;
				position: relative;

				image {
					width: 200rpx;
					height: 150rpx;
				}

				.time {
					background: #999;
					width: auto;
					padding: 0 8rpx;
					height: 30rpx;
					border-radius: 30rpx;
					font-size: 24rpx;
					position: absolute;
					right: 4rpx;
					bottom: 0;
					display: flex;
					align-items: center;
					color: #fff;

					.load {
						color: #fff;
					}
				}
			}

			.info {
				flex: 1;
				margin-left: 30rpx;
				display: flex;
				flex-direction: column;

				view {
					margin-bottom: 16rpx;
				}

				view:last-child {
					margin-bottom: 0;
				}

				.name {
					font-size: 28rpx;
				}

				.tips {
					font-size: 24rpx;
					color: #ccc;
				}
			}
		}

		.list:last-child {
			border-bottom: none;
		}
	}
</style>
